#pragma once

#include <zenoui/widgets/EmptyWidget.hpp>
#include <zenox/memory.hpp>
#include <zenox/generic_hash.hpp>
#include <tsl/robin_set.h>

namespace zenoui {

struct GraphicsItemWidget;

struct GraphicsViewWidget : EmptyWidget { // a widget visualizing graphics scene with graphics item, just like QGraphicsView
protected:
    void paint() override;
    void handle(MouseClickEvent *event) override;
    void handle(MouseMoveEvent *event) override;
    void handle(MouseWheelEvent *event) override;
    void handle(MouseReleaseEvent *event) override;
    using EmptyWidget::handle;

    void set_transform(Transform const &translation);
    Transform const &transform() const;

public:
    GraphicsViewWidget();
    ~GraphicsViewWidget();

protected:
    friend struct GraphicsItemWidget;

    tsl::robin_set<zenox::weak_ptr<GraphicsItemWidget>, zenox::pointer_hash, zenox::pointer_equal_to> m_selected_items;

    auto const &selected_items() const {
        return m_selected_items;
    }
};

}
